#include "StdAfx.h"
#include "ExampleFileVision.h"


CExampleFileVision::CExampleFileVision(void)
{
}


CExampleFileVision::~CExampleFileVision(void)
{
}

// MapMediaData
void CExampleFileVision::MapMediaData(void)
{	
	{
		pFrameCur = cvQueryFrame( pCapture );
		LPVOID pMap = MapViewOfFile(m_hOutputMapping,FILE_MAP_WRITE,0,0,0);
		if ((NULL != pMap) && (pFrameCur != NULL))
		{
			memset(pMap,0,BUFERNUM);
			char * pdata = (char * )pMap;
			memcpy( pdata, pFrameCur, sizeof(*pFrameCur));
			pdata +=sizeof(*pFrameCur);
			if( pFrameCur->imageData )
			{
				int size = pFrameCur->imageSize;
				memcpy( pdata, pFrameCur->imageData, size );
			}
		}
		UnmapViewOfFile((LPVOID)pMap); 
		//CloseHandle(pMap);
	}
	{
		LPVOID pMap = MapViewOfFile(m_hReadyMapping,FILE_MAP_WRITE,0,0,0);
		if (NULL != pMap)
		{
			memset(pMap,0,10);
			memcpy(pMap,"0",1);
		}
		UnmapViewOfFile((LPVOID)pMap); 
		//CloseHandle(pMap);
	}
}